package com.ftg.learn.amqp;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * 消费
 *
 * @author kangjx
 * @version 1.0
 * @date 2023/6/1 上午10:24
 */
@Component
public class ReceivComponent {

    @RabbitListener(queues = "hello")
    public void processMessage(String content) throws InterruptedException {
        System.out.println(content+"我就是hello里面的值");
        Thread.sleep(5000);
    }

    //微服务 [redis | mq | nacos (服务发现|配置中心) | sentinel(哨兵-nacos)|gateway (网关) |openfeign|resttemplate ]

    @RabbitListener(queues = "hello")
    public void processMessage1(String content) throws InterruptedException {
        System.out.println(content+"我就是hello里面的值，但是我方法1");
        Thread.sleep(5000);
    }

    /** *********工作队列******** */

    @RabbitListener(bindings = @QueueBinding(value = @Queue(),exchange = @Exchange(value = "telmess1",type="fanout")))
    public void processMessage2(String content) throws InterruptedException {
        System.out.println(content+"我就是hello里面的值，但是我方法1");
        Thread.sleep(5000);
    }
}
